<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Basic Layout - jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="css/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="css/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="css/mycss.css"/>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="js/util.js"></script>
</head>
<body>
<table id="weixin_msg_textrole_table"></table>
<script type="text/javascript">
    var $weixin_msg_textrole_table=$('#weixin_msg_textrole_table');
    $weixin_msg_textrole_table.datagrid({
        url:'data/textmsgrole.json',
        pagination:true,
        singleSelect:true,
        checkOnSelect:false,
        selectOnCheck:false,
        fit:true,
        edititem:[],
        columns: [
            [
                {field:'ck',checkbox:true},
                {field: 'id', title: 'RoleId'},
                {field: 'textkey', title: '关键词',editor: {type: 'textbox', options: {required: true}}},
                {field: 'enable', title: '是否开头', width: 80,editor: {type: 'checkbox', options: {on: 'true', off: 'false'}}},
                {
                    field:'sendid',
                    title:'消息处理器',
                    width:400,
                    formatter:function(value,row){
                        return row.sendname;
                    },
                    editor:{
                        type: 'combogrid',
                        options: {
                            required: true,
                            idField:'id',
                            textField:'retype',
                            url:'data/msgrole.json',
                            columns:[[
                                {field:'ck',checkbox:true},
                                {field: 'retype', title: '返回类型',width:100},
                                {field: 'msgid', title: '消息id'},
                                {field: 'stime', title: '开始时间', width: 180},
                                {field: 'endtime', title: '结束时间', width: 180},
                                {field: 'plugin', title: '对应插件', width: 180}
                            ]]
                        }
                    }
                }
            ]
        ],
        onBeforeEdit:function(rowIndex){
            var a = $weixin_msg_textrole_table.datagrid('options');
            a.edititem.push(rowIndex);
        },
        onDblClickRow:function(rowIndex){
            $weixin_msg_textrole_table.datagrid('beginEdit', rowIndex);
        },
        toolbar:[
            {
                iconCls:'icon-add',
                text:'添加',
                handler:function(){

                }
            },
            {
                iconCls: 'icon-save',
                text:'接受改变',
                handler:function(){
                    var a = $weixin_msg_textrole_table.datagrid('options');
                    $.each(a.edititem, function (i, n) {
                        var ed = $weixin_msg_textrole_table.datagrid('getEditor', {index:n,field:'sendid'});
                        rows[n]['sendname'] = $(ed.target).combogrid('getText');
                        $weixin_msg_textrole_table.datagrid('endEdit', n);
                    })
                }
            },
            {
                iconCls:'icon-save',
                text:'保存',
                handler:function(){

                }
            },
            {
                iconCls:'icon-cancel',
                text:'取消更改',
                handler:function(){

                }
            },
            {
                iconCls:'icon-remove',
                text:'删除',
                handler:function(){

                }
            }
        ]
    });
</script>
</body>
</html>